<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员登入</title>
<script
	src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="/park/bootstrap/css/bootstrap.min.css" >
<link rel="stylesheet" href="/park/bootstrap/css/bootstrap-theme.min.css" >
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >
<script src="/park/bootstrap/js/bootstrap.min.js" ></script>
<script src="/park/js/layer_mobile/layer.js?v=1.6"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js" ></script>
</head>
<body>
<h3 style="width: 96%;margin-left: 2%;text-align: center;">管理员登录</h3>
<div style="width: 96%;margin-left: 2%;margin-top: 30%;">
 <h4 style="text-align: left;">管理员账号:</h4>
  <div class="form-group">
    <input  style="margin-top: 20px;font-size: 18px;line-height: 46px;height: 46px;" type="number" class="form-control" id="loginName" placeholder="请输入登录账号">
  </div>
   <h4 style="text-align: left;">管理员密码:</h4>
  <div class="form-group">
    <input  style="margin-top: 20px;font-size: 18px;line-height: 46px;height: 46px;" type="password" class="form-control" id="passWord" placeholder="请输入您的密码">
  </div>
  <button type="button" style="width: 100%;font-size:18px;line-height: 38px;height: 46px;" class="btn btn-info" onclick="login()" >确&nbsp;&nbsp;认</button>
</div>
<script type="text/javascript">
$(function(){
	var admin = localStorage.getItem("admin_account");
	if(admin!=null&&admin!=''){
		$('#loginName').val(admin);
	}
})
function login(){
	var loginName = $('#loginName').val();
	var passWord = $('#passWord').val();
	if(loginName.length > 11){
        layer.open({
            content: '超出规定输入长度11位！'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
        return;
    }
    if(passWord.length > 20){
        layer.open({
            content: '密码超出规定长度！'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
        return;
    }
	if(loginName==''||loginName==null){
		layer.open({
		    content: '请输入管理员账号！'
		    ,skin: 'msg'
		    ,time: 2 //2秒后自动关闭
		  });
		return;
	}
    if(passWord==''||passWord==null){
        layer.open({
            content: '请输入密码！'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
        return;
    }
	$.ajax({
		url:'/park/data/help/login',
		data:'loginName='+loginName+'&passWord='+$('#passWord').val(),
		dataType:'json',
		success:function(res){
			if('200'==res.code){
				if(res.data.status==0){
					if(res.data.attr.streetNo!=null&&res.data.attr.streetNo!=''){
						$.ajax({
							url:'/park/data/help/setSession',
							data:'streetNo='+res.data.attr.streetNo,
							dataType:'json',
							success:function(res2){
								localStorage.setItem("admin_account",loginName);
                                layer.open({
                                    content: '登录成功！'
                                    ,skin: 'msg'
                                    ,time: 1 //2秒后自动关闭
                                });
                                setTimeout(function () {
                                    location.href = '/park/helpMain?streetNo='+res.data.attr.streetNo + '&loginName=' + loginName;
                                }, 1000);
							}
						})
					}
				}else{
					layer.open({
					    content: res.data.msg
					    ,skin: 'msg'
					    ,time: 2 //2秒后自动关闭
					  });
				}
			}else{
				layer.open({
				    content: res.data.msg
				    ,skin: 'msg'
				    ,time: 2 //2秒后自动关闭
				  });
			}
		}
	})
}
</script>
</body>
</html>